import { dateFormat as _dateFormat } from './../utils/date'
// 万数过滤
export function filterNum(num) {
  if(num == null) {
    return '0'
  }else if (num >= 0 && num <= 100000000) {
    return num > 10000 ? (num / 10000).toFixed(1) + "w" : num;
  } else if (num > 100000000) {
    return num > 100000000 ? (num / 100000000).toFixed(1) + "亿" : num;
  } else if (num < 0) {
    let newnum = Math.abs(num)
    if (newnum >= 0 && newnum <= 99999999) {
      return newnum > 10000 ? (newnum / 10000).toFixed(1) + "w" : newnum;
    } else if (newnum > 99999999) {
      return newnum > 100000000 ? (newnum / 100000000).toFixed(1) + "亿" : newnum;
    }
  }
}
// 万数汉字过滤
export function filterNumhan(num) {
  if(num === '无') {
    return '无'
  }
  if(num == null) {
    return '0'
  }else if(num == '无') {
    return '无'
  }else if (num >= 0 && num <= 100000000) {
    return num > 10000 ? (num / 10000).toFixed(1) + "万" : num;
  } else if (num > 100000000) {
    return num > 100000000 ? (num / 100000000).toFixed(1) + "亿" : num;
  } else if (num < 0) {
    let newnum = Math.abs(num)
    if (newnum >= 0 && newnum <= 99999999) {
      return newnum > 10000 ? (newnum / 10000).toFixed(1) + "万" : newnum;
    } else if (newnum > 99999999) {
      return newnum > 100000000 ? (newnum / 100000000).toFixed(1) + "亿" : newnum;
    }
  }
}

export function negativeNum(num) {
  let newnum = Math.abs(num)
  if (newnum >= 0 && newnum <= 99999999) {
    return '-' + (newnum > 10000 ? (newnum / 10000).toFixed(1) + "w" : newnum);
  } else if (newnum > 99999999) {
    return '-' + (newnum > 100000000 ? (newnum / 100000000).toFixed(1) + "亿" : newnum);
  }
}

// 无数据展示为--
export function nullData(str) {
  if(str == null || str == '' || str == '无') {
    return '无'
  }else {
    return str
  }
}

// 通知类别转义
export function noticeType(type) {
  if(type == null) {
    return '无'
  }else if(type == 0){
    return "临时任务通知"
  }else if(type == 1){
    return "活动报名通知"
  }else if(type == 2){
    return "活动开始通知"
  }else if(type == 3){
    return "作品推荐通知"
  }else if(type == 4){
    return "推荐情况反馈通知"
  }else if(type == 5) {
    return "推荐作品月报通知"
  }else if(type == 6) {
    return "提醒通知"
  }
}


export const dateFormat = _dateFormat